package com.turing.post.account.util;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

import com.turing.post.util.PCPSUtil;

@SuppressWarnings("serial")
@Entity
@Table(name = "MasterAccountTransferDetail")
@IdClass(MasterAccountTransferDetail.class)
public class MasterAccountTransferDetail implements Serializable {

	public MasterAccountTransferDetail() {
	}

	/**
	 * 主帐号
	 */
	private BigInteger masterAccNo;

	@Id
	@Column(name = "MasterAccNo", nullable = false)
	public BigInteger getMasterAccNo() {
		return masterAccNo;
	}

	public void setMasterAccNo(BigInteger masterAccNo) {
		this.masterAccNo = masterAccNo;
	}

	/**
	 * 银行账户ID
	 */
	private BigInteger bankAccountId;

	@Id
	@Column(name = "BankAccountId", nullable = true)
	public BigInteger getBankAccountId() {
		return bankAccountId;
	}

	public void setBankAccountId(BigInteger bankAccountId) {
		this.bankAccountId = bankAccountId;
	}

	/**
	 * 业务单ID
	 */
	private BigInteger ticketId;

	@Id
	@Column(name = "TicketId", nullable = false)
	public BigInteger getTicketId() {
		return ticketId;
	}

	public void setTicketId(BigInteger ticketId) {
		this.ticketId = ticketId;
	}

	/**
	 * 记账时间
	 */
	private Date tranTime;

	@Id
	@Column(name = "TranTime", nullable = false)
	public Date getTranTime() {
		return tranTime;
	}

	public void setTranTime(Date tranTime) {
		this.tranTime = tranTime;
	}

	/**
	 * 记账流水号
	 */
	private String accSeqNo;

	@Column(name = "AccSeqNo", nullable = false)
	public String getAccSeqNo() {
		return accSeqNo;
	}

	public void setAccSeqNo(String accSeqNo) {
		this.accSeqNo = accSeqNo;
	}

	/**
	 * 
	 * 转入金额
	 */
	private BigInteger transferInAmount;

	@Column(name = "TransferInAmount", nullable = false)
	public BigInteger getTransferInAmount() {
		return transferInAmount;
	}

	public void setTransferInAmount(BigInteger transferInAmount) {
		this.transferInAmount = transferInAmount;
	}

	/**
	 * 转出金额
	 */
	private BigInteger transferOutAmount;
	@Column(name = "TransferOutAmount", nullable = false)
	public BigInteger getTransferOutAmount() {
		return transferOutAmount;
	}

	public void setTransferOutAmount(BigInteger transferOutAmount) {
		this.transferOutAmount = transferOutAmount;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime
				* result
				+ ((this.getMasterAccNo() == null) ? 0 : this.getMasterAccNo()
						.hashCode());
		result = prime
				* result
				+ ((this.getBankAccountId() == null) ? 0 : this
						.getBankAccountId().hashCode());

		result = prime
				* result
				+ ((this.getTicketId() == null) ? 0 : this.getTicketId()
						.hashCode());

		result = prime
				* result
				+ ((this.getTranTime() == null) ? 0 : this.getTranTime()
						.hashCode());

		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof MasterAccountTransferDetail))
			return false;

		MasterAccountTransferDetail other = (MasterAccountTransferDetail) obj;

		if (!PCPSUtil.compareObject(this.getMasterAccNo(), other
				.getMasterAccNo()))
			return false;

		if (!PCPSUtil.compareObject(this.getBankAccountId(), other
				.getBankAccountId()))
			return false;

		if (!PCPSUtil.compareObject(this.getTicketId(), other.getTicketId()))
			return false;

		return PCPSUtil.compareObject(this.getTranTime(), other.getTranTime());
	}
}
